<template>
  <div class="register">
    <div class="main" v-if="isShow">
      <div class="main-title">Thank you for your submission! </div>
      <div class="main-text">
        Already have an account?
        <span style="color: #0060df; cursor: pointer" @click="signStop">Sign in</span>
      </div>

      <div class="main-block" >
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          class="demo-ruleForm"
        >
          <el-form-item label="Contact name" prop="name">
            <el-input
              v-model="ruleForm.name"
              placeholder="What's your contact name"
              clearable
            ></el-input>
          </el-form-item>

          <el-form-item label="Business name" prop="name1">
            <el-input
              v-model="ruleForm.name1"
              placeholder="Enter your business name"
              clearable
            ></el-input>
          </el-form-item>

          <el-form-item label="Email address" prop="address">
            <el-input
              v-model="ruleForm.address"
              placeholder="you@example.com"
              clearable
            ></el-input>
          </el-form-item>

          <el-form-item label="Password" prop="password">
            <el-input
              v-model="ruleForm.password"
              placeholder="Enter your password"
              show-password
            ></el-input>
          </el-form-item>

          <el-form-item label="Promo/Referral code (optional)" prop="optional">
            <el-input
              v-model="ruleForm.optional"
              placeholder="Ex:PROMO123"
              clearable
              suffix-icon="el-icon-question"
            ></el-input>
          </el-form-item>

          <div
            class="block-button"
            :style="{ background: ruleForm.name == '' ? '#e4e7f1' : '#0060df' }"
            @click="registerStop"
          >
            Register
          </div>
          <div class="block-text">
            By clicking "register", you agree to our
            <span style="color: #0060df">Terms of Service</span> and acknowledge
            to have read and understood our
            <span style="color: #0060df">Privacy Notice</span> and
            <span style="color: #0060df">Cookie Policy.</span>
          </div>
        </el-form>
      </div>

  </div>
    <div class="main" v-if="!isShow" style="height: 200px" >
      <div class="main-title" style="margin-top: 50px">Thank you for your submission!</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow:true,
      ruleForm: {
        name: "",
        name1: "",
        address: "",
        password: "",
        optional: "",
      },
      rules: {
        name: [{ required: true, message: "Contact name", trigger: "blur" }],
        name1: [{ required: true, message: "Business name", trigger: "blur" }],
        address: [{ required: true, message: "Email address", trigger: "blur" }],
        password: [{ required: true, message: "Password", trigger: "blur" }],
        optional: [{ required: true, message: "Promo/Referral code (optional)", trigger: "blur" }],
      },
    };
  },
  methods: {
    registerStop() {
        if(this.ruleForm.name == '') {
            return
        }

      if(this.ruleForm.name1 == '') {
        return
      }

      if(this.ruleForm.address == '') {
        return
      }

      if(this.ruleForm.password == '') {
        return
      }

      if(this.ruleForm.optional == '') {
        return
      }

        console.log('注册接口')

        this.isShow=false;
    },

    signStop() {
      this.$router.push({
        path: '/login'
      })
    }
  }
};
</script>

<style lang="less" scoped>
.register {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;

  .main {
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 20px 30px;
    box-sizing: border-box;

    .main-title {
      font-size: 40px;
      font-weight: bold;
      margin-bottom: 10px;
    }

    .main-text {
      font-size: 20px;
      color: #bbbdc2;
      letter-spacing: 0.5px;
    }

    .main-block {
      margin-top: 50px;

      /deep/ .el-form-item__label {
        line-height: 30px;
        font-size: 17px;
        color: #8d9099;
        font-weight: 500;
      }

      .block-button {
        width: 100%;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        border-radius: 5px;
        font-size: 16px;
        font-weight: bold;
        cursor: pointer;
      }

      .block-text {
        width: 400px;
        text-align: center;
        margin-top: 10px;
        font-size: 16px;
        line-height: 25px;
        font-weight: 500;
        color: #000;
      }
    }
  }
}
</style>
